package com.hctg.forced2sleep.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;

import com.actor.myandroidframework.utils.toaster.ToasterUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hctg.forced2sleep.R;
import com.hctg.forced2sleep.bean.MineItem;

/**
 * description: 权限Dialog
 * company    :
 *
 * @author : ldf
 * date       : 2024/6/11 on 09
 * @version 1.0
 */
public class PermissionListDialogAdapter extends BaseQuickAdapter<MineItem, BaseViewHolder> {

    public PermissionListDialogAdapter() {
        super(R.layout.item_permission_dialog_adapter);
        addChildClickViewIds(R.id.btn_video);
        setOnItemChildClickListener((adapter, view, position) -> {
            ToasterUtils.warning("跳转无障碍视频教程");
        });
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, MineItem item) {
        TextView tvContent = holder.setText(R.id.desc, item.subName)
                .setImageResource(R.id.iv_icon, item.resId)
                .getView(R.id.tv_content);
        tvContent.setText(item.name);
        tvContent.setSelected(item.hasPermission);

        //显示/隐藏按钮
        holder.setVisible(R.id.desc, item.visible);
        holder.setVisible(R.id.btn_video, !item.visible);
    }
}
